import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NumberWithdrawalsVO, NumberWithdrawalsForm, NumberWithdrawalsQuery } from '@/api/numberwithdrawals/numberWithdrawals/types';

/**
 * 查询会员提现管理列表
 * @param query
 * @returns {*}
 */

export const listNumberWithdrawals = (query?: NumberWithdrawalsQuery): AxiosPromise<NumberWithdrawalsVO[]> => {
  return request({
    url: '/numberWithdrawals/numberWithdrawals/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询会员提现管理详细
 * @param num
 */
export const getNumberWithdrawals = (num: string | number): AxiosPromise<NumberWithdrawalsVO> => {
  return request({
    url: '/numberWithdrawals/numberWithdrawals/' + num,
    method: 'get'
  });
};

/**
 * 新增会员提现管理
 * @param data
 */
export const addNumberWithdrawals = (data: NumberWithdrawalsForm) => {
  return request({
    url: '/numberWithdrawals/numberWithdrawals',
    method: 'post',
    data: data
  });
};

/**
 * 修改会员提现管理
 * @param data
 */
export const updateNumberWithdrawals = (data: NumberWithdrawalsForm) => {
  return request({
    url: '/numberWithdrawals/numberWithdrawals',
    method: 'put',
    data: data
  });
};

/**
 * 删除会员提现管理
 * @param num
 */
export const delNumberWithdrawals = (num: string | number | Array<string | number>) => {
  return request({
    url: '/numberWithdrawals/numberWithdrawals/' + num,
    method: 'delete'
  });
};


/**
 * 根据ID列表导出会员提现
 * @param nums 需要导出的会员提现列表
 */
export const exportSelectedWithdrawals = (nums: Array<string | number>): AxiosPromise<Blob> => {
  return request({
    url: '/numberWithdrawals/numberWithdrawals/exportSelected',
    method: 'post',
    data: nums,
    headers: {
      'Content-Type': 'application/json'
    },
    responseType: 'blob' // 确保响应类型为blob，以便处理文件下载
  });
};


/**
 * 清空表数据
 * 
 */
export const clearNumberWithdrawals = () => {
  return request({
    url: '/numberWithdrawals/numberWithdrawals/clear',
    method: 'delete'
  });
};